package appconfig

import (
	"fmt"

	"github.com/spf13/viper"
)

type Mysql struct {
	Host     string
	Port     int
	User     string
	Password string
	Database string
}
type Redis struct {
	Host     string
	Port     int
	Password string
	Database int
}
type SendSms struct {
	APIID  string
	APIKEY string
}

type Upload struct {
	AccessKey string
	SecretKey string
	Bucket    string
	Url       string
}

type AppConfig struct {
	Mysql   Mysql
	Redis   Redis
	SendSms SendSms
	Upload  Upload
}

var Conf AppConfig

func Init() {
	var err error
	viper.SetConfigFile("../appconfig/dev.yaml")
	err = viper.ReadInConfig()
	if err != nil {
		panic(err)
	}
	err = viper.Unmarshal(&Conf)
	if err != nil {
		panic(err)
	}
	fmt.Println(Conf)
}
